////////////////////////////////////////////////////////////////////////////////////////////////////
// file:	Entity/EntityPlayer.cpp
//
// summary:	Implements the entity player class
////////////////////////////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "EntityP.h"
#include "Lua/LuaWrapper.h"
#include "EntityLua.h"



EntityP::EntityP()
:EntityImp(Entity::ett_Player)
{
}

bool
EntityP::onLoad()
{
	EntityLua::push(Lua::instance()->state(), this);
	return Lua::instance()->call("Entity", "onLoadP", 1, 0);
}


//
//		sub entities management
//
IEntityManager*
EntityP::getEntityMgr()
{
	return &m_theSubEttMgr;
}


ICombatSys*
EntityP::getCombatSys()
{
	IEntity* pMainRole = m_theSubEttMgr.getEntity(1);
	if (pMainRole)
	{
		return pMainRole->getCombatSys();
	}
	else
	{
		return NULL;
	}
}

void
EntityP::setCombatSys(ICombatSys* pCombat)
{
	IEntity* pMainRole = m_theSubEttMgr.getEntity(1);
	if (pMainRole)
	{
		pMainRole->setCombatSys(pCombat);
	}
}

int		
EntityP::getProps(const short& nIdx, int d)const
{
	EntityManager mgr(m_theSubEttMgr);
	IEntity* pMainRole = mgr.getEntity(1);
	if (pMainRole)
	{
		return pMainRole->getProps(nIdx, d);
	}
	else
	{
		return 0;
	}
}

void	
EntityP::setProps(const short& nIdx, int v)	
{
	IEntity* pMainRole = m_theSubEttMgr.getEntity(1);
	if (pMainRole)
	{
		pMainRole->setProps(nIdx, v);
	}
}